import { h } from "koishi"

export const name = "雪豹exit"

export function apply(ctx) {
  var why = [
    'whatlang 为一门大致上基于栈',
    'bind 指令可用于在多个平台间绑定用户数据',
  ]

  ctx.before("command/execute", argv => {
    if (why.some(i => argv.source?.startsWith(i))) {
      session.isDirect || argv.session.onebot?._request("set_msg_emoji_like", { message_id: argv.session.event.message.id, emoji_id: 89 })
      return []
    }
  })

  var why2 = ['ba', 'ma', 'md', 'nb', 'wc', '喜报', '悲报', '😰', 'teha', 'whatlang', 'wl', 'stl']
  ctx.middleware((session, next) => {
    if (!session.resolve(ctx.root.config.prefix).includes("")) return next()
    if (!session.stripped.prefix && why2.includes(session.stripped.content.trim().toLowerCase())) {
      session.isDirect || session.onebot?._request("set_msg_emoji_like", { message_id: session.event.message.id, emoji_id: 277 })
      return
    }

    if (
      session.resolve(ctx.root.config.prefix).includes("") &&
      session.elements.length === 1 &&
      session.elements[0].type === "face" &&
      session.elements[0].attrs.platform === "onebot" &&
      session.elements[0].attrs.id == 277
    )
      session.isDirect || session.onebot?._request("set_msg_emoji_like", { message_id: session.event.message.id, emoji_id: "😰".codePointAt(0) })

    return next()
  }, { prepend: true })
}
